package tech.dx.springdb.controller;

import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import tech.dx.springdb.entity.Teacher;
import tech.dx.springdb.service.TeacherService;

/**
 * @ClassName TeacherController
 * @Description TODO
 * @Author omg
 * @Date 2019/4/5 14:37
 * @Version 1.0
 */
@RestController
@RequestMapping("teacher")
@Api(tags = {"教师"})
public class TeacherController {
    @Autowired
    private TeacherService teacherService;

    @GetMapping("/{id}")
    public Teacher get(@PathVariable long id) {
        return teacherService.getById(id);
    }

    @PostMapping
    public Teacher add(@RequestBody Teacher t) {
        return teacherService.add(t);
    }
    @PutMapping
    public Teacher update(@RequestBody Teacher t) {
        return teacherService.update(t);
    }

}
